#ifndef PACK_H
#define PACK_H

#include <QString>
#include <QStringList>

enum type_t{
    LOGIN=1,
    LOGOUT,
    REGIST,
    HOUSE_ADD,//直播间的创建、列表查询、删除与修改
    HOUSE_LIST,
    HOUSE_DELETE,
    HOUSE_UPDATE,
    HOUSE_ENTER,//进入直播间
    HOUSE_EXIT,//退出直播间
    HOUSE_MSG,//直播间的实时消息
    HOUSE_MEMS,//直播间的成员列表
    VIDEO, //视频流
    CAMERA, //摄像头数据流
    BULLET, //弹幕
    GIFT//送礼物
};

enum frame_t{
    CALL=1,
    RET
};


class Pack
{
private:
    int packsize;
    type_t type;
    frame_t frame;
    char buf[4096];//2字节字段长度，字段内容；...
    int buflen;
    QStringList fieldList;
public:
    Pack():packsize(12),buflen(0){};
    Pack(type_t type, frame_t frame):packsize(12),type(type),frame(frame),buflen(0){}
    void setType(type_t type){this->type=type;}
    type_t getType(){return this->type;}
    void setFrame(frame_t frame){this->frame=frame;}
    frame_t getFrame(){return frame;}
    void setPacksize(int packsize){this->packsize=packsize;};
    int getPacksize(){return this->packsize;}
    int getBuflen(){return this->buflen;}
    void setFieldList(QStringList & list){this->fieldList=list;};
    QStringList& getFieldList(){return fieldList;}

    //拼报
    void append(const QString & rs);

};

#endif // PACK_H
